package com.sdry.web.controller.base;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sdry.entity.base.Department;
import com.sdry.entity.base.Staff;
import com.sdry.service.base.DepartmentService;

@Controller
public class mainController {
	@Resource
	private DepartmentService departmentService;
	/**
	 * 首页
	 * @return
	 */
	@RequestMapping("/main")
	public String index(HttpSession session,Model model) {
		Staff userSession = (Staff) session.getAttribute("staff");
        String staffname = userSession.getScode();
        Department department = departmentService.queryById(userSession.getDid());
        model.addAttribute("department",department);
        model.addAttribute("staff",userSession);
        String main = "/main";
        if(null != staffname && !"".endsWith(staffname)) {
    	    String js = userSession.getSreserve3();
        	if(staffname.endsWith("admin")) {
    	    	main = "/main2";
    	    }else if("业务管理员".equals(js)){
    	    	main = "/main3";
    	    }else if("管理员".equals(js)){
    	    	main = "/main2";
    	    }
        }
		return main;
	}

}
